#include <iostream>
using namespace std;


//自定义函数对象
//1.使用类实现函数对象
class MyFunctionObject
{
    public:
        int operator()(int a,int b){
            return a + b;
        }
};


//2.使用结构体实现函数对象
struct MyStructFunctionObjeect{
    int operator()(int a,int b){
        return a*b;
    }
};


// int main(){
//     MyFunctionObject obj;
//     int result = obj(3,4);
//     cout << "Result: " << result << endl;
//     return 0;
// }


//使用lambda表达式(C++11及以上)
int main(){
    auto lambdaObj = [](int a,int b){return a -b;};
    int result = lambdaObj(5,3);
    cout << "result: " << result << endl;
    return 0;
}